let AdBannerControll = require('../common/AdBannerControll');
let BannerMoveCasual = require('../common/BannerMoveCasual');
//弹出视图基类
cc.Class({
  extends: cc.Component,
  properties: {},
  ctor() {
    this.clientData = null;
  },
  onLoad() {
    this.showBanner(false);
  },
  
  onEnable() {
  
  },
  start() {
  
  },
  onDisable() {
    cc.CEventManager.instance.releaseAllEvents(this);
  },
  
  setClientData(data) {
    this.clientData = data;
  },
  
  getClientData() {
    return this.clientData;
  },
  
  closeView() {
    this.beforeCloseView();
    if (this.node.closeView) {
      this.node.closeView();
    } else {
      this.node.destroy();
    }
  },
  
  beforeCloseView() {
    //子类可重新实现此接口
  },
  
  afterPopup() {
    let bannerMoveCasual = this.node.getComponent(BannerMoveCasual);
    if(!bannerMoveCasual) {
      this.showBanner(true);
    }
  },
  
  showBanner(show) {
    let adBannerControll = this.node.getComponent(AdBannerControll);
    if (adBannerControll) {
      adBannerControll.enabled = show;
    }
  },
  hideBanner(){
    this.showBanner(false);
  }
});
